package com.wutianyi.module.services.impl;

import java.util.List;

import org.apache.commons.collections.CollectionUtils;
import org.apache.shiro.crypto.hash.Sha512Hash;

import com.wutianyi.module.company.Company;
import com.wutianyi.module.member.dataobject.MemberDO;
import com.wutianyi.module.services.CompanyServices;
import com.wutianyi.module.services.MemberServices;

public class InitServicesImpl {

	private CompanyServices companyServices;
	private MemberServices memberServices;

	public void init() {
		List<Company> companys = companyServices.listCompanys();
		if (CollectionUtils.isEmpty(companys)) {
			Company company = companyServices.createCompany("天之翼", "天之翼的网站");
			MemberDO member = new MemberDO();
			member.setcId(company.getId());
			member.setCompanyId(company.getCompanyId());
			member.setName("wutianyi");
			member.setPassword(new Sha512Hash("hello1234").toString());
			memberServices.createMember(member);
		}
	}

	public CompanyServices getCompanyServices() {
		return companyServices;
	}

	public void setCompanyServices(CompanyServices companyServices) {
		this.companyServices = companyServices;
	}

	public MemberServices getMemberServices() {
		return memberServices;
	}

	public void setMemberServices(MemberServices memberServices) {
		this.memberServices = memberServices;
	}

}
